<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('对接学生')" />
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <p>弹出复选框表格及单选框表格（点击提交后得到数据）。 </p>
            <button type="button" class="btn btn-primary" onclick="selectCheckUser()">选择学生</button>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <h5>确认学生</h5>
            <table id="bootstrap-table"></table>
        </div>

    </div>
</div>
<th:block th:include="include :: footer" />


<script th:inline="javascript">
    var sexData = [[${@dict.getType('sys_user_sex')}]];
    var prefix = ctx + "system/tutor";
    $(function() {
        var options = {
            url: prefix + "/myStuList",
            showSearch: false,
            showRefresh: false,
            showToggle: false,
            showColumns: false,
            pagination: false,
            columns: [
                {
                    field: 'stuSno',
                    title: '学号'
                },
                {
                    field: 'sysUser.userName',
                    title: '姓名'
                },
                {
                    field: 'sysUser.sex',
                    title: '性别',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(sexData, value);
                    }
                },
                {
                    field: 'sysUser.phonenumber',
                    title: '电话'
                },
                {
                    field: 'intention1',
                    title: '选择意向'
                },
                {
                    field: 'intention2',
                    title: '选择意向'
                }
            ]
        };
        $.table.init(options);
    });
</script>

<script type="text/javascript">
    var prefix = ctx + "system/tutor";

    function selectCheckUser(){
        var count =    [[${count}]];
        var titleCount =    [[${titleCount}]];
        //判断第一个表里有没有数据
        var lie = $("#bootstrap-table").find("tr").find("td").length;
        //判断第二个表里数据是否为2
        var rows = $('#bootstrap-table').find("tr").length;

        if(rows===count+1 || (lie === 1&&count === 0))
        {
            if(count===titleCount){
                alert("无可选择")
            }else
                $.modal.open("已单向选择学生列表", prefix + "/check");

        }

    }
</script>


</body>
</html>

